<?php
/**
 * Created by PhpStorm.
 * User: shaowei
 * Date: 2019/7/19
 * Time: 下午2:05
 */

namespace App\Http\Model;


use Illuminate\Support\Facades\Redis;


class RoomMelee
{
    private $redisRoomMelee = "ROOM:MELEE:"; //ROOM:MELEE::{room_id}


    /**
     * 设置是否开启团战
     * @param $roomId
     * @param $opened
     * @return mixed
     */
    public function setState($roomId, $opened){
        $key = $this->redisRoomMelee . $roomId;
        if (empty($opened)){
            return Redis::DEL($key);
        }
        return Redis::SET($key, 1);
    }

    /**
     * 获取是否是开启状态
     * @param $roomId
     * @return integer
     */
    public function getState($roomId){
        $key = $this->redisRoomMelee . $roomId;
        $val = Redis::GET($key);
        if (empty($val)){
            return 0;
        }
        return intval($val);
    }

}